<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCustomersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customers', function (Blueprint $table) {
            $table->engine='InnoDB';
            $table->increments('id')->comment('客户ID');
            $table->integer('customer_level')->comment('客户等级');
            $table->string('customer_type',10)->comment('客户类别');
            $table->string('Customer status',16)->comment('客户状态');
            $table->string('company_size',30)->comment('公司规模');
            $table->string('company_address',30)->comment('公司地址');
            $table->unsignedInteger('contact_id')->nullable()->default(0)->comment('联系人');
            $table->foreign('contact_id')->references('id')->on('contacts')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedInteger('finance_id')->nullable()->default(0)->comment('财务');
            $table->foreign('finance_id')->references('id')->on('finances')->onUpdate('cascade')->onDelete('cascade');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customers');
    }
}
